package com.cosmoplat.xikai.business.controller;

import com.cosmoplat.xikai.business.domain.dto.materialRequirement.MaterialRequirementQueryDTO;
import com.cosmoplat.xikai.business.domain.dto.materialRequirement.MaterialStockModifyDTO;
import com.cosmoplat.xikai.business.domain.vo.MaterialRequirementVo;
import com.cosmoplat.xikai.business.service.MaterialRequirementService;
import com.cosmoplat.xikai.common.core.controller.BaseController;
import com.cosmoplat.xikai.common.core.domain.AjaxResult;
import com.cosmoplat.xikai.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName MaterialRequirementController
 * @Description 物料需求管理
 * @Author wdf
 * @Date 2025/1/7
 */
@Api(tags = "物料需求管理", value = "物料需求管理")
@RestController
@Slf4j
@RequestMapping("/materialRequirement")
public class MaterialRequirementController extends BaseController {

    @Autowired
    private MaterialRequirementService materialRequirementService;


    /**
     * 查询生产计划列表
     *
     * @param queryDTO
     * @return com.cosmoplat.xikai.common.core.page.TableDataInfo
     * @date 16:22 2025/1/7
     **/
    @ApiOperation(value = "分页查询")
    @PreAuthorize("@ss.hasPermi('business:materialRequirement:query')")
    @GetMapping("/queryForPage")
    public TableDataInfo<MaterialRequirementVo> queryForPage(MaterialRequirementQueryDTO queryDTO) {
        startPage();
        List<MaterialRequirementVo> list = materialRequirementService.queryForPage(queryDTO);
        return getDataTable(list);
    }

    /**
     * 修改库存
     *
     * @param stockModifyDTO
     * @return com.cosmoplat.xikai.common.core.domain.AjaxResult
     * @date 16:37 2025/1/7
     **/
    @ApiOperation(value = "修改库存")
    @PreAuthorize("@ss.hasPermi('business:materialRequirement:modifyMaterialStock')")
    @PostMapping("/modifyMaterialStock")
    public AjaxResult modifyMaterialStock(@RequestBody @Validated MaterialStockModifyDTO stockModifyDTO) {
        materialRequirementService.modifyMaterialStock(stockModifyDTO);
        return AjaxResult.success();
    }
}
